#! /bin/bash

killService(){
  echo $1;
  pid=$(getPid $1);
  if [ "$pid" !=  "" ];then
        echo $pid
        kill -9 $pid
  fi
}

getPid(){
  ps -ax | grep "$1" | grep -v grep | awk '{print $1}' | xargs
}

startAliveApi(){
    nohup python3 /home/ubuntu/alive_backbone/alive_api/start_alive_api_server.py --port=10001 > /dev/null &
    nohup python3 /home/ubuntu/alive_backbone/alive_api/start_alive_api_server.py --port=10002 > /dev/null &
    nohup python3 /home/ubuntu/alive_backbone/alive_api/start_alive_api_server.py --port=10003 > /dev/null &
    nohup python3 /home/ubuntu/alive_backbone/alive_api/start_alive_api_server.py --port=10004 > /dev/null &
}

echo "restart";
killService "alive_api";
startAliveApi;




